package com.bysj.studentsystem.vo;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ClassName ResponseDataVO
 * @Description: 应答报文
 * @Author: xubao@wair.ac.cn
 * @Date: 2023/9/18 10:41
 */
@Data
@NoArgsConstructor
public class ResponseDataVO<T> {
    private Integer code;
    private String message;
    private T data;

    public ResponseDataVO<T> ok(){
        this.code = 200;
        this.message = "success";
        this.data = null;
        return this;
    }

    public ResponseDataVO<T> ok(String message){
        this.code = 200;
        this.message = message;
        this.data = null;
        return this;
    }

    public ResponseDataVO<T> ok(T data){
        this.code = 200;
        this.message = "success";
        this.data = data;
        return this;
    }

    public ResponseDataVO<T> fail(){
        this.code = 0;
        this.message = "fail";
        this.data = null;
        return this;
    }

    public ResponseDataVO<T> fail(String msg){
        this.code = 0;
        this.message = msg;
        this.data = null;
        return this;
    }
}
